/**
 * Assignment 5            P5Rectangle.java                Due July 20, 2011
 *
 * login: cs11ubn
 */

/**
 * Rectangle object that inherits Shape. Defines area and volume methods from
 * shape and overrides the toString method.
 */
public class P5Rectangle extends P5Shape
{
  protected double width, height; // Vars for width and height

  /**
   * No-arg ctor. Initialize to one
   */
  public P5Rectangle()
  {
    width = 1; // Init to 1
    height = 1; // Init to 1
  }

  /**
   * 2-arg ctor. Makes a rectangle with the given width and height
   */
  public P5Rectangle(double w, double h)
  {
    width = w; // Set width
    height = h; // Set height
  }

  /**
   * Define the area method from Shape
   */
  public double area()
  {
    return width * height; // Area of a rectangle
  }

  /**
   * Define the volume method from Shape
   */
  public double volume()
  {
    return area(); // The volume is the area
  }

  /**
   * Override the toString method.
   */
  public String toString()
  {
    return "Rectangle:\t" + width + " x " + height; // Rectangle output
  }
}
